package com.neusoft.approveserver.controller;


import com.neusoft.approveserver.dto.ApprovalAdd;
import com.neusoft.approveserver.dto.ApprovalStatusUpdate;
import com.neusoft.approveserver.dto.ChanceSearchRole;
import com.neusoft.approveserver.dto.RespBean;
import com.neusoft.approveserver.entity.Approval;
import com.neusoft.approveserver.service.IApprovalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 机会审批记录表 前端控制器
 * </p>
 *
 * @author victor
 * @since 2021-07-18
 */
@RestController
@RequestMapping("/approve")
public class ApprovalController {
    @Autowired
    IApprovalService iApprovalService;
    @PostMapping("/addChanceApproval")
    RespBean addChanceApproval(@RequestBody ApprovalAdd approvalAdd){
        return iApprovalService.addChanceApproval(approvalAdd);
    }
    @PostMapping("/queryAllApproval")
    RespBean queryAllApproval(){
        return iApprovalService.queryAllApproval();
    }
    @PostMapping("/getApprovalByChanceId/{chanceId}")
    RespBean getApprovalByChanceId(@PathVariable Integer chanceId){
        return iApprovalService.getApprovalByChanceId(chanceId);
    }

    @PostMapping("/getLatestApprovalByChanceId/{chanceId}")
    RespBean getLatestApprovalByChanceId(@PathVariable Integer chanceId){
        return iApprovalService.getLatestApprovalByChanceId(chanceId);
    }

    @PostMapping("/updateLatestApproval")
    RespBean updateLatestApprovalByChanceId(@RequestBody ApprovalStatusUpdate approvalStatusUpdate){
        return iApprovalService.updateLatestApprovalByChanceId(approvalStatusUpdate);
    }
    @PostMapping("/searchChanceByUserRole")
    RespBean searchChanceByUserRole(@RequestBody ChanceSearchRole chanceSearchRole){
        return iApprovalService.searchChanceByUserRole(chanceSearchRole);
    }
}

